{template header}
<div class="cru"><a href="{SITE_URL}">{$setting['site_name']}</a> &gt;&gt; 提出问题</div>
<div class="listBody">
	<div class="block">
		<div class="title">
			<h3>提出问题</h3>
		</div>
		<div class="postForms">
			<form name="askform" onsubmit="return check_askform(this);" action="index.php?c=question&a=add" method="post">
				<table cellspacing="3" cellpadding="3" width="100%">
					<tr>
						<td width="12%">提问标题：</td>
						<td>
							<input type="text" value="{$word}" id="title" name="title" size="60" class="sHistory" >
							<span class="num">(4-20个字)</span>
						</td>
					</tr>
					<tr>
						<td>提问内容：</td>
						<td>
							<textarea id="mydescription" name="description" rows="15" cols="70" class="sHistory" style="color: rgb(153, 153, 153);"></textarea>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td class="tips">可以对您的提问补充细节，以得到更准确的答案。</td>
					</tr>
					<tr>
						<td>问题类别：</td>
						<td>
							<table  align="left" cellspacing="0" cellpadding="0" border="0">
									<tr>
										<td>
											<select id="ClassLevel1" style="WIDTH: 125px" size="8" name="classlevel1">
												<option selected></option>
											</select>
										</td>
										<td width="20">
											<div align="center"><b>→</b></div>
										</td>
										<td>
											<select id="ClassLevel2" style="WIDTH: 125px" size="8" name="classlevel2">
												<option selected></option>
											</select>
										</td>
										<td width="20">
											<div id="jiantou" align="center"><b>→</b></div>
										</td>
										<td>
											<select id="ClassLevel3" style="WIDTH: 125px" onchange="getCidValue();" size="8" name="classlevel3">
												<option selected></option>
											</select>
										</td>
									</tr>
								</table>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td class="tips">如果您的问题无法归入任何子分类，您可以只选择一级分类。</td>
					</tr>	
					<tr>
						<td>悬赏财富：</td>
						<td>
							<select  name="givescore">
								<option value="0" selected>0</option>
								<option value="5">5</option>
								<option value="10">10</option>
								<option value="15">15</option>
								<option value="20">20</option>
								<option value="30">30</option>
								<option value="50">50</option>
								<option value="80">80</option>
								<option value="100">100</option>
							</select>
							<span class="num">您目前的财富值：{$user['credit2']}</span></td>
					</tr>
					<tr>
						<td>匿名提问：</td>
						<td ><input  type="checkbox" value="1" name="hidanswer"></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td class="tips">您可以对问题设定匿名，但您需要付出财富值10分。</td>
					</tr>
					<!--{if $setting['code_ask']}-->
					<tr>
						<td>验证码：</td>
						<td ><input maxlength="4" name="code" size="10" />&nbsp;&nbsp;<img id="verifycode" onclick="javascript:updatecode();" src="index.php?c=user&a=code"/>&nbsp;<span id="codetip"><a href="javascript:updatecode();">看不清，换一个</a></span></td>
					</tr>
					<!--{/if}-->
					<tr>
						<td>&nbsp;</td>
						<td>
							<input type="hidden" value="0" name="cid">
							<input type="hidden" value="$askfromuid" name="askfromuid">
							<input class="btn" type="submit" value="好了，提交" name="submit">
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>


<script charset="utf-8" src="{SITE_URL}js/editor/kindeditor.js"></script>
<script type="text/javascript">
 
	KE.show({
		id : 'mydescription',
		resizeMode : 1,
		shadowMode : false,
		allowUpload : true,
		newlineTag : 'br',
		imageUploadJson : g_site_url+'index.php?attach/upload',
		items : ['fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',	'insertunorderedlist', '|','image', 'link']
	});
</script>


<script type="text/javascript">
	var sortobj=eval('($category_js)');
	var g_ClassLevel1;
	var g_ClassLevel2;
	var g_ClassLevel3;
	var class_level_1=sortobj.category1;
	var class_level_2=sortobj.category2;
	var class_level_3=sortobj.category3;
	var button_noselect="不选择";

function getCidValue()
{
	var _cl1 = document.askform.ClassLevel1;
	var _cl2 = document.askform.ClassLevel2;
	var _cl3 = document.askform.ClassLevel3;
	var _cid = document.askform.cid;
	if(_cl1.value!=0) _cid.value = _cl1.value;
	if(_cl2.value!=0) _cid.value = _cl2.value;
	if(_cl3.value!=0) _cid.value = _cl3.value;
}
function FillClassLevel1(ClassLevel1)
{
    ClassLevel1.options[0] = new Option("aa", "0");
    for(i=0; i<class_level_1.length; i++)
    {
        ClassLevel1.options[i] = new Option(class_level_1[i][1], class_level_1[i][0]);
    }
    // ClassLevel1.options[0].selected = true;
    ClassLevel1.length = i;
}
function FillClassLevel2(ClassLevel2, class_level_1_id)
{
    ClassLevel2.options[0] = new Option(button_noselect, "");
    count = 1;
    for(i=0; i<class_level_2.length; i++){
    if(class_level_2[i][0].toString() == class_level_1_id) {
            ClassLevel2.options[count] = new Option(class_level_2[i][2], class_level_2[i][1]);
            count = count+1;}
    }
    ClassLevel2.options[0].selected = true;
    ClassLevel2.length = count;
}
function FillClassLevel3(ClassLevel3, class_level_2_id)
{
    ClassLevel3.options[0] = new Option(button_noselect, "");
    count = 1;
    for(i=0; i<class_level_3.length; i++) {
        if(class_level_3[i][0].toString() == class_level_2_id) {
            ClassLevel3.options[count] = new Option(class_level_3[i][2], class_level_3[i][1]);
            count = count+1;}
    }
    ClassLevel3.options[0].selected = true;
    ClassLevel3.length = count;       
}
function ClassLevel2_onchange()
{
    getCidValue();
    FillClassLevel3(g_ClassLevel3, g_ClassLevel2.value); 
    if (g_ClassLevel3.length <= 1) {  
     g_ClassLevel3.style.display = "none";
	 document.getElementById("jiantou").style.display = "none";
    }
    else {
     g_ClassLevel3.style.display = "";     
	 document.getElementById("jiantou").style.display = "";	 
    }       
}
 
function ClassLevel1_onchange()
{
    getCidValue();
    FillClassLevel2(g_ClassLevel2, g_ClassLevel1.value);
    ClassLevel2_onchange();
	
}
function InitClassLevelList(ClassLevel1, ClassLevel2, ClassLevel3)
{
    g_ClassLevel1=ClassLevel1;
    g_ClassLevel2=ClassLevel2;
    g_ClassLevel3=ClassLevel3;
    g_ClassLevel1.onchange = Function("ClassLevel1_onchange();");
    g_ClassLevel2.onchange = Function("ClassLevel2_onchange();");
    FillClassLevel1(g_ClassLevel1);
    ClassLevel1_onchange();
}
InitClassLevelList(document.askform.ClassLevel1, document.askform.ClassLevel2, document.askform.ClassLevel3);

var selected_id_list="0"
var blank_pos = selected_id_list.indexOf(" ");
var find_blank = true;
if (blank_pos == -1) {
    find_blank = false;
    blank_pos = selected_id_list.length;
}
var id_str = selected_id_list.substr(0, blank_pos);
g_ClassLevel1.value = id_str;
ClassLevel1_onchange();

if (find_blank == true) {
    selected_id_list = selected_id_list.substr(blank_pos + 1,   selected_id_list.length - blank_pos - 1);
    blank_pos = selected_id_list.indexOf(" ");
    if (blank_pos == -1) {
        find_blank = false;
        blank_pos = selected_id_list.length;
    }
    id_str = selected_id_list.substr(0, blank_pos);
    g_ClassLevel2.value = id_str;
    ClassLevel2_onchange();

    if (find_blank == true) {
        selected_id_list = selected_id_list.substr(blank_pos + 1,  selected_id_list.length - blank_pos - 1);
        blank_pos = selected_id_list.indexOf(" ");
        if (blank_pos == -1) {
            find_blank = false;
            blank_pos = selected_id_list.length;
        }
        id_str = selected_id_list.substr(0, blank_pos);
        g_ClassLevel3.value = id_str;
    }
}

/*体交检查*/
function check_askform(obj){
    if ( bytes(obj.title.value) < 4) {
      alert("问题标题不能少于4字！");
      obj.title.focus();
      return false;    
    }
    /*
	if(obj.description.value ==""){
		alert("问题描述不能为空!");
		obj.description.focus();
		return false;
	}*/
	if(obj.classlevel1.selectedIndex==-1){
		alert("没有选择分类!");
		return false;
	}
	//检查财富值是否够用
	var offerscore=0;
	if(obj.hidanswer.checked)offerscore+=10;
	offerscore+=parseInt(obj.givescore.value);
	if(offerscore>{$user['credit2']}){
		alert("你的财富值不够!");
		return false;
	}
}
</script>


{template footer}